package com.study.netty.nio;

import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

public class MappedByteBufferTest {


    public static void main(String[] args) throws Exception {
        // MappedByteBuffer 可让文件直接在内存(堆外内存)修改,操作系统不需要拷贝一次
        RandomAccessFile randomAccessFile = new RandomAccessFile("d://1.txt","rw");

        FileChannel fileChannel = randomAccessFile.getChannel();
        MappedByteBuffer buffer = fileChannel.map(FileChannel.MapMode.READ_WRITE,0,5);

        randomAccessFile.close();
    }
}
